﻿define(["jQuery", "kendo", "config", "utils", "localdata"],
        function ($, kendo, config, utils, localdata) {

            //private functions
            var _handleRedirection = function () {
                console.log('entering: viewModel.index._handleRedirection');
                //alert('inside init');
                if (localdata.localRegistrationFound) {
                    //user device is registered

                    if (localdata.isMultipleType) {
                        //has multiple, so give him the screen to select
                        utils.navigate("../views/moduleselection.html");
                    }
                    else {
                        //user is registered and has one module, direct him to the right one
                        switch (localdata.usermainmodule) {
                            case "passenger":
                                utils.navigate(config.paths.passengerMain);
                                break;
                            case "driver":
                                utils.navigate(config.paths.driverMain);
                                break;
                            case "company":
                                utils.navigate(config.paths.companyMain);
                                break;
                        }
                    }
                }
                else {
                    //user device is not registered....
                    utils.navigate("views/firsttime.html");
                }
            }

            /*RETURN*/
          return {
             
              //init
              init: function (initEvent) {
                  console.log('entering: viewModel.index.init');
              },

              //show
              show: function () {
                  console.log('entering: viewModel.index.show');
                  $('#slogan').hide();
                  $('#slogan').fadeIn(100, function () {
                      $(this).delay(100).fadeOut(100, function () {
                          // window.location = 'pages/pagemanager.html';
                          _handleRedirection();
                      });
                  });
              }
        }
    });